package com.jinbo.footmessageworker.person;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.jinbo.footmessageworker.R;
import com.jinbo.footmessageworker.httpbean.ProjectBean;
import com.jinbo.footmessageworker.order.HistoryOrderDetailActivity;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by jinbo on 2015/8/19.
 */
public class ServerItemListViewAdapter extends BaseAdapter {


    static class ViewHolder {
        TextView tv_name,tv_duration,tv_price;
    }

        List<ProjectBean> projects;
        private Context context;
        public ServerItemListViewAdapter(Context context,List<ProjectBean> dataList){//ArrayList<ProjectsBean> datalist) {
            this.context=context;
            this.projects=dataList;

        }

    void setprojects( List<ProjectBean>  projects)
    {
        this.projects=projects;
    }


        @Override
        public int getCount() {
            // TODO Auto-generated method stub*//*
            if (projects != null) {
                return projects.size();
            }
            return  0;
        }

        @Override
        public Object getItem(int position) {
            // TODO Auto-generated method stub
            if (projects != null) {
                return projects.get(position);
            }
            return null;
        }

        @Override
        public long getItemId(int position) {
            // TODO Auto-generated method stub
            return position;
        }

        @Override

        public View getView(final int position, View convertView, ViewGroup arg2)
        {
            ViewHolder holder = null;
            if (convertView == null) {
                convertView = LayoutInflater.from(context).inflate(R.layout.item_kind, null);
                holder = new ViewHolder();
                holder.tv_name=(TextView)convertView.findViewById(R.id.name);
                holder.tv_duration=(TextView)convertView.findViewById(R.id.duration);
                holder.tv_price=(TextView)convertView.findViewById(R.id.price);
                convertView.setTag(holder);
            } else {
                holder = (ViewHolder) convertView.getTag();
            }
            holder.tv_name.setText(projects.get(position).name);
            holder.tv_duration.setText(projects.get(position).duration+"分钟");
            holder.tv_price.setText(projects.get(position).price+"元");
            return convertView;
        }
}
